<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of PDFReport
 *
 * @author Marlon
 */
require(RUTA_PDF.'fpdf.php');
class PDFReport extends FPDF{
var $A4x=210 ;
var $A4y=297;
function crearPdf($titulo,$rutaCuadro,$cabeceraTabl,$data){
    
    
    $ancho=150;
    $alto=80;
    
    $this->AddPage();
    $this->SetFont('Arial','B',16);
    $this->SetTitle($titulo,true);
    
   $this->ImprovedTable($cabeceraTabl, $data,50,10);
   
    $this->Image($rutaCuadro,round(($this->A4x-$ancho)/2),round($this->A4y/2),$ancho,$alto);
    $this->Ln(10);
    
    
}
function crearPDFTabla($titulo,$cabeceraTabl,$data,$ancho,$altoCelda){
    $this->AddPage('L','A4');  
    // Select Arial bold 15
    $this->SetFont('Arial','BU',15);
    // Move to the right
    $this->Cell(round($this->A4y/2)-30);
    // Framed title
    $this->Cell(30,10,$titulo,0,0,'C');
    // Line break
    $this->Ln(20);
    $this->SetFont('Arial','B',12);
    
    
   $this->ImprovedTable($cabeceraTabl, $data,$ancho,$altoCelda);
    $this->Ln(10);
}
function total($titulo){
    // Move to the right
    $this->Cell(round($this->A4y/3)-30);
    // Framed title
    $this->Cell(30,10,'Total: S/.'.$titulo,0,0,'C');
}
function ImprovedTable($header, $data,$anchoCelda,$altoCelda)
{
    $numCol=count($header);
    
    $w =$anchoCelda;
    $v=$altoCelda;
    // Cabeceras
    for($i=0;$i<$numCol;$i++)
        $this->Cell($w,$v,$header[$i],1,0,'C');
    $this->Ln();
    // Datos
     $this->SetFont('Arial','',12);
    foreach($data as $row)
        
    {   $sum=0;
        for($m=0;$m<count($row);$m++){
            $this->Cell($w ,$v,$row[$m],1);
            $sum=$sum+$w;
        }
        
        $this->Ln();
    }

}

}

?>
